<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>表单页面验证</title>
</head>

<body>
    <form id="f1" action="./login" method="post">
        <input type="text" name="usrname" />
        <input type="password" name="pwd" />
        <input type="button" value="登录" id="btnLogin" />
    </form>
</body>
<script src="jquery-1.12.4.js"></script>
<script>
    $(function () {
        $('#btnLogin').click(function () {
            let data = $("#f1").serialize();
            $.ajax({
                url: '/login',
                method: 'post',
                data: data,
                success: function (backData) {
                    alert(backData.msg);

                    if (backData.code == 200) {
                        window.location = '/list';
                    }
                }
            });
        });
    })
</script>

</html>